<#assign menu="system">
<#assign submenu="system_basic">
<#include "/system/head.ftl">
<!--main content start-->
<section id="main-content">
	<section class="wrapper">
    	<!-- page start-->
    	<div class="row">
		<div class="col-lg-12">
		<section class="panel">
			<header class="panel-heading">
					修改系统配置
			</header>
				<form id="basicForm" action="" role="form" class="form-horizontal" autocomplete="off" method="post" >
			<div class="panel-body">
					<div class="form-group">
						<label class="col-lg-2 col-sm-2 control-label" for="inputEmail1">网站名称</label>
						<div class="col-lg-10">
							<input type="text" placeholder="网站名称" id="siteName" name="siteName"
								class="form-control" value="${SYS_SITENAME}">
						</div>
					</div>
					<div class="form-group">
						<label class="col-lg-2 col-sm-2 control-label" for="inputEmail1">网站描述</label>
						<div class="col-lg-10">
							<input type="text" placeholder="网站描述" id="siteDesc" name="siteDesc"
								class="form-control" value="${SYS_SITEDESC}">
						</div>
					</div>
					<div class="form-group">
						<label class="col-lg-2 col-sm-2 control-label" for="inputEmail1">网站关键词</label>
						<div class="col-lg-10">
							<input type="text" placeholder="网站关键词,逗号隔开" id="keywords" name="Keywords"
								class="form-control" value="<#if SYS_KEYWORDS??>${SYS_KEYWORDS}</#if>">
						</div>
					</div>
					<div class="form-group">
                          <label class="col-sm-2 col-sm-2 control-label">网站模板</label>
                          <div class="col-sm-10">
							<select class="form-control input-lg m-bot15" style="font-size:15px;width: 300px;" id="template" name="template">
		                   		<#list templeteList as template>
		                        	<option style="background-color:#DFF0D8;font-weight:bold;" value="${template}" <#if (THEME==template)>selected</#if>>
		                        		${template}
		                        	</option>
		                        </#list>
                            </select>                                        
                          </div>
                      </div> 
          			<div class="form-group">
                          <label class="col-sm-2 col-sm-2 control-label">是否开启缓存</label>
                          <div class="col-sm-10">
                          	<label class="radio-inline">
                        		<input type="radio" name="cache" value="1" <#if (CACHE=='1')>checked</#if>/> 开启
                      		</label>
                      		<label class="radio-inline">
                        		<input type="radio" name="cache" value="0" <#if (CACHE=='0')>checked</#if>/> 关闭
                      		</label>
                      		<label class="col-lg-offset-1 ">
                      			<button class="btn btn-danger" type="button" onClick="clearHtml();">清理缓存</button>
                      		</label>
                          </div>
                      </div>
                  </div>
                   <header class="panel-heading">
					用户配置
				   </header>
				 <div class="panel-body">
                   <div class="form-group">
						<label class="col-lg-2 col-sm-2 control-label" for="SYS_SUB_GOLD">激活扣除金币数</label>
						<div class="col-lg-10">
							<input type="text" placeholder="激活扣除金币数" id="SYS_SUB_GOLD" name="SYS_SUB_GOLD"
								class="form-control" style="width: 300px;display: inline-block;" value="<#if SYS_SUB_GOLD??>${SYS_SUB_GOLD}<#else>1500</#if>">
						</div>
					</div>
                      
                    <div class="form-group">
						<label class="col-lg-2 col-sm-2 control-label" for="referPercent">直推百分比</label>
						<div class="col-lg-10">
							<input type="text" placeholder="直推百分比" id="referPercent" name="referPercent"
								class="form-control"  style="width: 300px;display: inline-block;" value="<#if referPercent??>${referPercent}<#else>15</#if>"> 
								<label>%</label>
						</div>
					</div>
                      
                    <div class="form-group">
						<label class="col-lg-2 col-sm-2 control-label" for="pointParent">点点百分比</label>
						<div class="col-lg-10">
							<input type="text" placeholder="点点百分比" id="pointParent" name="pointParent"
								class="form-control"  style="width: 300px;display: inline-block;" value="<#if pointParent??>${pointParent}<#else>15</#if>"> %
						</div>
					</div>
					
					<div class="form-group">
						<label class="col-lg-2 col-sm-2 control-label" for="subPointParent">点点百分比递减率</label>
						<div class="col-lg-10">
							<input type="text" placeholder="点点百分比递减率" id="subPointParent" name="subPointParent"
								class="form-control"  style="width: 300px;display: inline-block;" value="<#if subPointParent??>${subPointParent}<#else>80</#if>"> %
						</div>
					</div>
					
					
					<div class="form-group">
						<label class="col-lg-2 col-sm-2 control-label" for="maxLevel">点点层级数</label>
						<div class="col-lg-10">
							<input type="text" placeholder="点点层级数" id="maxLevel" name="maxLevel"
								class="form-control"  style="width: 300px;display: inline-block;" value="<#if maxLevel??>${maxLevel}<#else>10</#if>">层
						</div>
					</div>
                      
                     <div class="form-group">
						<label class="col-lg-2 col-sm-2 control-label" for="goldToMoneyPercent">金币兑换比率</label>
						<div class="col-lg-10">1元=
							<input type="text" placeholder="金币兑换比率" id="goldToMoneyPercent" name="goldToMoneyPercent"
								class="form-control"  style="width: 300px;display: inline-block;" value="<#if goldToMoneyPercent??>${goldToMoneyPercent}<#else>1</#if>">个金币
						</div>
					</div>
                       
                    <#list listConfig as config>
					<#if (config.cmsKey=="inputMoneyCenterPercent")>
                    <div class="form-group">
						<label class="col-lg-2 col-sm-2 control-label" for="inputMoneyCenterPercent">充值报单中心费率</label>
						<div class="col-lg-10">
							<input type="text" placeholder="充值时，报单中心费赚取的手续费" id="inputMoneyCenterPercent" name="inputMoneyCenterPercent"
								class="form-control"  style="width: 300px;display: inline-block;" value="${config.cmsValue}">%
						</div>
					</div>
					</#if>
					<#if (config.cmsKey=="outputMoneyCenterPercent")>
					<div class="form-group">
						<label class="col-lg-2 col-sm-2 control-label" for="goldToMoneyPercent">提现报单中心费率</label>
						<div class="col-lg-10">
							<input type="text" placeholder="提现时，报单中心费赚取的手续费" id="outputMoneyCenterPercent" name="outputMoneyCenterPercent"
								class="form-control"  style="width: 300px;display: inline-block;" value="${config.cmsValue}">%
						</div>
					</div>
					</#if>
					</#list>
					
					<div class="form-group">
						<div class="col-lg-offset-2 col-lg-10">
							<button class="btn btn-danger" type="submit">保存</button>
						</div>
					</div>
				</form>
			</div>
		</section>
	</div>
	</div>
    	<!-- page end-->
     </section>
</section>
<!--main content end-->

<script type="text/javascript">

function ajaxSubmit(){  
    if( $("#basicForm").valid()){  
       $.ajax(
		{
			url:"${basePath}/admin/config/basic.json",
			type:"post",
			data:$("#basicForm").serialize(),
			dataType:"json",
			success:function(data){
				if (data.result) {
					bootbox.alert("保存成功，将刷新页面", function() {
						window.location.reload();
					});					
				}else{
					showErrors($('#basicForm'),data.errors);
				}
			},
			error:function(XMLHttpRequest, textStatus, errorThrown){
				bootbox.alert({  
		            buttons: {  
		               ok: {  
		                    label: '关闭'
		               }  
		            },  
		            message: data.responseText,
		            title: "错误",  
		        });
			}
		});
    }  
} 
function clearHtml(){
	alert("删除html文件");
}
$().ready(function() {
 $("#basicForm").validate({
        rules: {
		   //inputMoneyCenterPercent: "required"
		   inputMoneyCenterPercent: {
					required: true,
					number: true
			}
		 },
        messages: {
		   //inputMoneyCenterPercent: "请输入充值费率"
		   inputMoneyCenterPercent: {
					required: "请输入充值费率",
					number: "请输入有效小数"
				}
		},   
        submitHandler: function(form) {  
            //alert('要提交了!');  
            //1. 不可用 $(form).submit();否则会死循环  
            //2. 如果 form.submit()也不用，此表单就不会自动提交了  
            //form.submit();  
            //3. 下面是 ajax 提交  
            ajaxSubmit();  
        } 
    });
});
</script>

<#include "/system/foot.ftl">